home *** CD-ROM | disk | FTP | other *** search
/ Aminet 37 / Aminet 37 (2000)(Schatztruhe)[!][Jun 2000].iso / Aminet / dev / basic / PureBasic.lha / PureBasic_Demo / PureBasic / Examples / FullVersion_Sources / Menu.pb < prev    next >
Encoding:
Text File  |  2000-03-19  |  2.0 KB  |  103 lines

  1. ;
  2. ; *********************************
  3. ;
  4. ; Menus example file for Pure Basic
  5. ;
  6. ;   © 1999 - Fantaisie Software -
  7. ;
  8. ; *********************************
  9. ;
  10. ;
  11.  
  12. InitScreen  (0)    ; We need 1 screen
  13. InitWindow  (0)    ; 1 window
  14. InitTagList (10)   ; a taglist upto 11 tags
  15. InitMenu    (0,30) ; 1 menu with maximum 30 items
  16.  
  17. FindScreen (0,"")  ; Find the default screen
  18.  
  19. ShowScreen()       ; Bring it to front of the display
  20.  
  21. ;
  22. ; Here are all our menus strings...
  23. ;
  24.  
  25. Title1.s = "Project"
  26. Item1.s  = "Open..."  : Short1.s = ""
  27. Item2.s  = "Brush"    : Short2.s = "B"
  28. Item3.s  = "Picture"  : Short3.s = "P"
  29. Item4.s  = "Save as..."    : Short4.s = "S"
  30. Item5.s  = "Compression"  : Short5.s = ""
  31. Item6.s  = "Quit"     : Short6.s = "Q"
  32.  
  33. ;
  34. ; Build the menus (note the indentation which is important)
  35. ;
  36.  
  37. MenuTitle(Title1)
  38.  
  39.   MenuItem (1, Item1, 0)
  40.     MenuSubItem (2, Item2, Short2)
  41.     MenuSubBar  ()
  42.     MenuSubItem (3, Item3, Short3)
  43.  
  44.   MenuItem      (4, Item4, Short4)
  45.   MenuCheckItem (5, Item5, Short5, 1)
  46.   MenuBar       ()
  47.   MenuItem      (6, Item6, Short6)    ; Quit
  48.  
  49. CreateMenu(0, ScreenID())  ; Create our menu
  50.  
  51. WinTitle.s = "Menu example"
  52.  
  53. ResetTagList (#WA_Title, WinTitle)
  54.      AddTag (#WA_SmartRefresh,1)
  55.      AddTag (#WA_CustomScreen, ScreenID())
  56.      AddTag (#WA_NewLookMenus, 1)
  57.  
  58. If OpenWindow(0, 100, 40, 300, 100, #WFLG_CLOSEGADGET | #WFLG_DRAGBAR | #WFLG_DEPTHGADGET | #WFLG_ACTIVATE, TagListID())
  59.  
  60.   AttachMenu(0,WindowID())  ; Attach our menu to the opened window
  61.  
  62.   Compression = 1
  63.  
  64.   Repeat
  65.     VWait()
  66.     IDCMP.l = WindowEvent()
  67.  
  68.     If IDCMP = #IDCMP_MENUPICK
  69.       Select EventGadget()
  70.  
  71.         Case 2
  72.           PrintN("Sub-Menu 'Brush'")
  73.  
  74.         Case 3
  75.           PrintN("Sub-Menu 'Picture'")
  76.  
  77.         Case 4
  78.           PrintN("Menu 'Save As...'")
  79.  
  80.         Case 5
  81.           Print("Menu 'Compression=")
  82.  
  83.           Compression = 1-Compression
  84.  
  85.           If Compression
  86.             PrintN("On")
  87.           Else
  88.             PrintN("Off")
  89.           EndIf
  90.  
  91.         Case 6
  92.           IDCMP = #IDCMP_CLOSEWINDOW
  93.  
  94.       EndSelect        
  95.  
  96.     EndIf
  97.  
  98.   Until IDCMP = #IDCMP_CLOSEWINDOW
  99.  
  100. EndIf
  101.  
  102. End
  103.